﻿//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NetCMS.Content;
using NetCMS.Model;
public partial class manage_channel_special_list_ajax : NetCMS.Web.UI.ManagePage
{
    public string ChID = string.Empty;
    Channel rd = new Channel();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (SiteID != "0")
            {
                PageError("分站没权限操作", "javascript:history.back();", true);
            }
            ChID = Request.QueryString["ChID"];
            string ParentID = Request.QueryString["ParentID"];
            string str = Request.QueryString["str"];
            if (ChID != null && ChID != string.Empty)
            {
                if (ParentID == string.Empty && ParentID == null)
                {
                    Response.Write("错误的参数");
                }
                else
                {
                    StartLoad(1, int.Parse(ParentID.ToString()), str.ToString());
                }
            }
            else
            {
                Response.Write("错误的参数");
            }
        }
    }

    protected void StartLoad(int PageIndex, int ParentID, string TmpSTR1)
    {
        int i, j;
        string strchar = "";
        SQLConditionInfo[] st = new SQLConditionInfo[2];
        st[0] = new SQLConditionInfo("@ChID", int.Parse(ChID.ToString()));
        st[1] = new SQLConditionInfo("@ParentID", ParentID);
        DataTable dt = Pagination.GetPage("manage_channel_special_list_aspx", PageIndex, 50, out i, out j, st);
        if (dt != null && dt.Rows.Count > 0)
        {

            dt.Columns.Add("CName", typeof(string));
            dt.Columns.Add("OrderIDs", typeof(string));
            dt.Columns.Add("ST", typeof(string));
            dt.Columns.Add("OP", typeof(string));
            dt.Columns.Add("Colum", typeof(string));
            for (int k = 0; k < dt.Rows.Count; k++)
            {
                dt.Rows[k]["CName"] = "<a href=\"special_add.aspx?sId=" + dt.Rows[k]["ID"].ToString() + "&ChID=" + ChID + "&Action=Edit\" class=\"list_link\" title=\"点击修改\">" + dt.Rows[k]["specialCName"].ToString() + "(" + dt.Rows[k]["specialEName"].ToString() + ")</a>";
                dt.Rows[k]["OrderIDs"] = "<a href=\"javascript:orderAction(" + dt.Rows[k]["ID"] + "," + dt.Rows[k]["OrderID"] + ");\" class=\"list_link\" title=\"点击修改权重\"><strong>" + dt.Rows[k]["OrderID"].ToString() + "</strong></a>";
                if (dt.Rows[k]["islock"].ToString() == "1")
                {
                    dt.Rows[k]["ST"] = "&nbsp;&nbsp;<span class=\"reshow\">已锁定</span>&nbsp;&nbsp;";
                }
                else
                {
                    dt.Rows[k]["ST"] = "&nbsp;&nbsp;正常&nbsp;&nbsp;";
                }
                dt.Rows[k]["OP"] += "<input type=\"checkbox\" Name=\"gID\" value=\"" + dt.Rows[k]["id"].ToString() + "\">";
                dt.Rows[k]["OP"] += "<a href=\"special_add.aspx?ChID=" + Request.QueryString["ChID"] + "&sId=" + dt.Rows[k]["id"].ToString() + "&Action=Edit\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/edit.gif\" border=\"0\"></a>";
                dt.Rows[k]["OP"] += "<a target=\"_blank\" href=\"preview.aspx?ChID=" + Request.QueryString["ChID"] + "&id=" + dt.Rows[k]["id"].ToString() + "&type=class\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/review.gif\" border=\"0\"></a>";
                dt.Rows[k]["OP"] += "<a href=\"special_add.aspx?ChID=" + Request.QueryString["ChID"] + "&SpecialID=" + dt.Rows[k]["id"].ToString() + "\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/addclass.gif\" border=\"0\"></a>";
                string TmpFolder = string.Empty;
                string TmpSTR = string.Empty;
                int ClassNumber = rd.getSpecialNumber(int.Parse(dt.Rows[k]["id"].ToString()));
                if (ClassNumber > 0)
                {
                    TmpFolder = "<img src=\"../../sysImages/folder/yess.gif\" border=\"0\" title=\"此专题下有" + ClassNumber + "个专题\">";
                    TmpSTR = "<a href=\"###\" class=\"list_link\" onclick=\"ajaxGetClass('" + dt.Rows[k]["id"].ToString() + "','div_" + dt.Rows[k]["id"].ToString() + "','" + TmpSTR1 + "')\">" + TmpFolder + "</a>";
                }
                else
                {
                    TmpFolder = "<img src=\"../../sysImages/folder/nos.gif\" border=\"0\" title=\"此专题下有0个专题\">";
                    TmpSTR = TmpFolder;
                }
                strchar += "<div>";
                strchar += "(" + dt.Rows[k]["OrderIDs"] + ")&nbsp;";
                strchar += TmpSTR + "<span class=\"reshow\">(" + ClassNumber + ")</span>" + dt.Rows[k]["specialCName"] + "&nbsp;<a title=\"此专题下的信息\" href=\"Content.aspx?ChID=" + Request.QueryString["ChID"] + "&stat=SP|" + dt.Rows[k]["id"].ToString() + "\">[" + rd.GetSpecialInfoCount(int.Parse(dt.Rows[k]["id"].ToString()), int.Parse(Request.QueryString["ChID"].ToString())) + "]</a>";
                strchar += dt.Rows[k]["ST"];
                strchar += dt.Rows[k]["OP"];
                if (ClassNumber > 0)
                {
                    strchar += "<div style=\"width:100%;display:none;\" class=\"SubItem\" id=\"div_" + dt.Rows[k]["id"].ToString() + "\">loading...";
                    strchar += "</div>";
                }
                strchar += "</div>";
            }
            dt.Clear();
        }
        Response.Write(strchar);
    }
}
